<?php
/**
 * Created by PhpStorm.
 * User: chenzhitao
 * Date: 2018/5/6
 * Time: 下午3:39
 */

namespace App\Busi\Modules\Resource;


use App\Busi\Modules\BaseBusi;
use App\Http\Requests\VoucherListRo;
use App\Models\Voucher;

class VoucherListBusi extends BaseBusi
{
    public function handle(VoucherListRo $ro){
        $page = $ro->page;
        $where = [
            ['flag','=',1]
        ];
        $pageSize = 5;
        $fields = ['name','price','amount',"phone"];
        $data = Voucher::where($where)->select($fields)->paginate($pageSize);
        $total = $data->total();
        $pageNum =  ceil($total/$pageSize);
        $currentPage = $data->currentPage();
        $data = $data->toArray();
        $ret = [
            "pageNum"=>$pageNum,
            "currentPage"=>$currentPage,
            "data"=>$data['data']
        ];
        return $ret;
    }
}